package zju.ccnt.exception;

import org.springframework.http.HttpStatus;

/**
 * Created by zha on 14/11/5.
 * base exception
 * sub class should add annotation like
 *      @ResponseStatus(value = HttpStatus.CONFLICT, reason = "Duplicate user found")
 * when sub exception was caught, spring-mvc would return a http response with the exception message
 *
 */
public abstract class BaseWebApplicationException extends RuntimeException{
    private final int status ;

    public BaseWebApplicationException(HttpStatus status, String msg, Throwable t) {
        super(msg, t);
        this.status = status.value();
    }

    public BaseWebApplicationException(HttpStatus status, String message) {
        super(message);
        this.status = status.value();
    }

    public int getStatus() {
        return status;
    }

}
